<template>
  <div class="simple-client-info">
    <!-- 客户信息头部 -->
    <div class="client-header">
      <div class="client-avatar">
        <div class="avatar-placeholder">
          {{ client?.name?.charAt(0) || '客' }}
        </div>
        <div class="status-indicator status-indicator--online"></div>
      </div>
      
      <div class="client-basic">
        <h3 class="client-name">{{ client?.name || '未知客户' }}</h3>
        <p class="client-status">在线</p>
      </div>

      <div class="client-actions">
        <button class="action-btn" title="编辑客户信息">
          <i class="icon-edit">✏️</i>
        </button>
        <button class="action-btn" title="查看历史记录">
          <i class="icon-history">📋</i>
        </button>
      </div>
    </div>

    <!-- 客户详细信息 -->
    <div class="client-details">
      <!-- 客户标签 -->
      <div v-if="client?.tags?.length" class="info-section">
        <h4 class="section-title">标签</h4>
        <div class="tags-container">
          <span 
            v-for="tag in client.tags" 
            :key="tag.id"
            class="tag"
            :style="{ backgroundColor: tag.color }"
          >
            {{ tag.name }}
          </span>
        </div>
      </div>

      <!-- 统计信息 -->
      <div class="info-section">
        <h4 class="section-title">统计信息</h4>
        <div class="stats-grid">
          <div class="stat-item">
            <span class="stat-label">店铺消费</span>
            <span class="stat-value">¥ —</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">平均客单价</span>
            <span class="stat-value">¥ —</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">收藏好评率</span>
            <span class="stat-value">100%</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">发货好评率</span>
            <span class="stat-value">100%</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">注册时间</span>
            <span class="stat-value">{{ formatDate(client?.createdAt) }}</span>
          </div>
        </div>
      </div>

      <!-- 操作按钮 -->
      <div class="action-buttons">
        <button class="action-btn-block">添加备注</button>
        <button class="action-btn-block">发收藏夹</button>
        <button class="action-btn-block">加入人群</button>
      </div>

      <!-- 底部标签页 -->
      <div class="bottom-tabs">
        <div class="tab active">客服备忘</div>
        <div class="tab">记录</div>
        <div class="tab">清单</div>
      </div>

      <!-- 备忘区域 -->
      <div class="memo-area">
        <div class="memo-placeholder">暂无数据</div>
      </div>
    </div>
  </div>
</template>

<script setup>
// Props
const props = defineProps({
  client: {
    type: Object,
    default: () => null
  }
})

// Methods
const formatDate = (date) => {
  if (!date) return '—'
  return new Date(date).toLocaleDateString('zh-CN')
}
</script>

<style scoped>
.simple-client-info {
  width: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.client-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.client-avatar {
  position: relative;
  flex-shrink: 0;
}

.client-avatar .avatar-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
  color: #666;
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.status-indicator--online {
  background: #52c41a;
}

.client-basic {
  flex: 1;
  min-width: 0;
}

.client-name {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-status {
  margin: 0;
  font-size: 12px;
  color: #52c41a;
}

.client-actions {
  display: flex;
  gap: 4px;
}

.action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #666;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f5f5f5;
  color: #1890ff;
}

.client-details {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.info-section {
  margin-bottom: 24px;
}

.section-title {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  color: white;
  font-weight: 500;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fafafa;
  border-radius: 6px;
  font-size: 12px;
}

.stat-label {
  color: #666;
}

.stat-value {
  color: #333;
  font-weight: 500;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.action-btn-block {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.action-btn-block:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.bottom-tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab.active {
  color: #1890ff;
  border-bottom-color: #1890ff;
}

.tab:hover {
  color: #1890ff;
}

.memo-area {
  text-align: center;
  color: #999;
  font-size: 14px;
  padding: 40px 0;
}

.memo-placeholder {
  opacity: 0.6;
}

/* 滚动条样式 */
.client-details::-webkit-scrollbar {
  width: 4px;
}

.client-details::-webkit-scrollbar-track {
  background: transparent;
}

.client-details::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 2px;
}

.client-details::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}
</style>